/***     
 * SP_FIVE_FOUR_ONE: 10, // 四带一张
 */

var _ = require('../Underscore');
var CardTool = require('../CardTool');
var CardGroupType = require('./CardGroupType');
var FindSameCardValueTool = require('./../FindTool/FindSameCardValueTool');

var GroupFourAndOneTool = module.exports = {};


GroupFourAndOneTool.getName = function() {
    return '四带一张';
};

GroupFourAndOneTool.getType = function() {
    return CardGroupType.SP_FIVE_FOUR_ONE;
};

GroupFourAndOneTool.getMoreResult = function(_cardInfoList) {
    var resultInfo = FindSameCardValueTool.getResult(_cardInfoList, 4);
    var findGroupMore = [];
    var otherGroup = [];

    var result = {};
    if (resultInfo.isFind) {
        var findGroup = resultInfo.findGroup;
        _.each(findGroup, function(singleGroup) {
            var otherGroup = _.difference(_cardInfoList, singleGroup);
            var tmpFindGroup = _.clone(singleGroup);
            tmpFindGroup.push(_.last(otherGroup));
            otherGroup = _.initial(otherGroup);
            var info = {
                findGroup: tmpFindGroup,
                otherGroup: otherGroup
            }
            findGroupMore.push(info);
        });

        result = {
            isFind: resultInfo.isFind,
            findGroupMore: findGroupMore,
        }
    } else {
        result = {
            isFind: false,
            findGroupMore: [],
            otherGroup: _cardInfoList
        };
    }
    CardTool.LogResult(result, this.getName());
    return result;
};